class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        string ret;
        int minLen = strs[0].size();
        for (auto& s : strs)
        {
            if (s.size() < minLen)
                minLen = s.size();
        }
        for (int i = 0; i < minLen; i++)
        {
            char c = strs[0][i];
            int j;
            for (j = 0; j < strs.size(); j++)
            {
                if (c != strs[j][i])
                    break;
            }
            if (j < strs.size())
                break;
            else
                ret += c;
        }
        return ret;
    }
};